package com.ruoyi.web.controller.teacher;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.BasisTypicalObjectives;
import com.ruoyi.service.IBasisTypicalObjectivesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 典型目标管理Controller
 * 
 * @author wangzebing
 * @date 2025-03-27
 */
@RestController
@RequestMapping("/objectives")
public class BasisTypicalObjectivesController extends BaseController
{
    @Autowired
    private IBasisTypicalObjectivesService basisTypicalObjectivesService;

    /**
     * 查询典型目标管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BasisTypicalObjectives basisTypicalObjectives)
    {
        startPage();
        List<BasisTypicalObjectives> list = basisTypicalObjectivesService.selectBasisTypicalObjectivesList(basisTypicalObjectives);
        return getDataTable(list);
    }

    /**
     * 导出典型目标管理列表
     */
    @Log(title = "典型目标管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasisTypicalObjectives basisTypicalObjectives)
    {
        List<BasisTypicalObjectives> list = basisTypicalObjectivesService.selectBasisTypicalObjectivesList(basisTypicalObjectives);
        ExcelUtil<BasisTypicalObjectives> util = new ExcelUtil<BasisTypicalObjectives>(BasisTypicalObjectives.class);
        util.exportExcel(response, list, "典型目标管理数据");
    }

    /**
     * 获取典型目标管理详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(basisTypicalObjectivesService.selectBasisTypicalObjectivesById(id));
    }

    /**
     * 新增典型目标管理
     */
    @Log(title = "典型目标管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasisTypicalObjectives basisTypicalObjectives)
    {
        return toAjax(basisTypicalObjectivesService.insertBasisTypicalObjectives(basisTypicalObjectives));
    }

    /**
     * 修改典型目标管理
     */
    @Log(title = "典型目标管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasisTypicalObjectives basisTypicalObjectives)
    {
        return toAjax(basisTypicalObjectivesService.updateBasisTypicalObjectives(basisTypicalObjectives));
    }

    /**
     * 删除典型目标管理
     */
    @Log(title = "典型目标管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(basisTypicalObjectivesService.deleteBasisTypicalObjectivesByIds(ids));
    }



    /**
     * 查询典型目标管理列表
     */
    @GetMapping("/findAllBasisTypicalObjectives")
    public AjaxResult findAllBasisTypicalObjectives()
    {
        List<BasisTypicalObjectives> list = basisTypicalObjectivesService.findAllBasisTypicalObjectives(new BasisTypicalObjectives());
        return success(list);
    }
}
